package com.lzq.online_learning_system.comm;

import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.http.HttpServletRequest;

/**
 * @ClassName AbstractBaseCtrl
 * @Description TODO
 * @Author Administrator
 * @Date 2019/10/15 0015 14:15
 * @Version 1.0
 */
public abstract class AbstractBaseCtrl {
    @Autowired
    protected HttpServletRequest request;

    protected ResultVO success(Object data){
        return new ResultVO<>(data);
    }
    protected ResultVO success(Object count,Object data){
        return new ResultVO<>(count,data);
    }
    protected ResultVO success(){
        return new ResultVO<>();
    }
    protected ResultVO success(String token,Object data){
        return new ResultVO<>(token,data);
    }
    protected ResultVO success(String token,Object count,Object data){
        return new ResultVO<>(token,count,data);
    }

    /*protected PageResultVO success(IPage page){
        return new PageResultVO(page.getRecords(),page.getCurrent(),page.getSize(),page.getTotal());
    }*/

    protected ResultVO failed(){
        return new ResultVO<>(false,"5001","失败",null);
    }

    protected ResultVO exception(){
        return new ResultVO<>(false,"500","异常",null);
    }

    protected ResultVO error(){
        return new ResultVO<>(false,"600","错误",null);
    }

    protected ResultVO error(String msg){
        return new ResultVO<>(false,"600",msg,null);
    }
}
